
package com.coldchain.common.msg;

import com.coldchain.common.constant.RestCodeConstants;

import java.io.Serializable;

import org.springframework.http.HttpStatus;

/**
 * 返回数据
 */
public class BaseResponse implements Serializable {
    private int status = 200;
    private String message;

    public BaseResponse(int status, String message) {
        this.status = status;
        this.message = message;
    }

    public BaseResponse() {
    }
    public BaseResponse succeed(){

        return  this.succeed("ok");
    }
    public BaseResponse succeed(String message){
        this.status= HttpStatus.OK.value();
        this.message=message;
        return this;
    }

    public  BaseResponse error(){
        return  this.error(RestCodeConstants.EX_BUSINESS_BASE_CODE,"error");
    }
    public  BaseResponse error(String error){
        return  this.error(RestCodeConstants.EX_BUSINESS_BASE_CODE,error);
    }
    public  BaseResponse error(int code,String error){
        this.status= code;
        this.message=error;
        return this;
    }
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }


}
